
<%@page import="ll.sms.web.*"%><%@ page language="java" import="java.util.*,ll.sms.pojo.*,org.json.simple.*" pageEncoding="UTF-8"%>
<%@page import="ll.sms.util.*"%>
<%@page import="org.apache.commons.lang.*"%>
<%
String currentUserId = SmsUtil.sessionHelper(session,AdminProperty.aid);
String sort = ParamUtils.getParameter(request,"sort");
int index = ParamUtils.getIntParameter(request,"start",0);
int pageSize = ParamUtils.getIntParameter(request,"limit",15);
int currentPage = 1+(index/pageSize);
String dir = request.getParameter("dir");
if(dir == null){
	dir = "ASC";
}

String orderStr = null;
if(sort != null && !sort.equals("")){
	orderStr = " "+sort+" "+dir+" ";
}

//被选中的业务员
String selectOperator = request.getParameter("opreator");

String ids = ParamUtils.getParameter(request,"ids");

if("add".equals(ParamUtils.getParameter(request,"flag"))){
	String  oId = ParamUtils.getParameter(request,"opid");
	if(StringUtils.isBlank(oId)){return;}
			out.print(WebBusinessImpl.getInstance().assignAddUser(oId,ids));

	return;
}

/////////////////////////////////
if("remove".equals(ParamUtils.getParameter(request,"flag"))){
	   out.print(WebBusinessImpl.getInstance().assignCancelUser(selectOperator,ids));
		return;
}

/////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//业务操作，展示属于该业务员管辖的成员列表
if("behindoperator".equals(request.getParameter("flag"))){

	if(StringUtils.isBlank(selectOperator)){return;}//若未选中任何业务员，则跳过

int total = WebBusinessImpl.getInstance().countTable("sms_operator"," where oadminid='"+selectOperator+"' ");

String s = ExtJsonBuilder.toExtJsonString(total,  WebBusinessImpl.getInstance().findAlUserByOperatorID(selectOperator));
response.getWriter().print(s);
return;
}
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
//查询属于该代理的所有用户（若已经选择了业务员，那么将限定为该业务员）
if("behindproxy".equals(request.getParameter("flag"))){
String con =null;
if(StringUtils.isBlank(selectOperator)){//若未选定业务员，那么将显示该代理下所有的用户
    con = " where ucompany = '"+currentUserId+"'";
	int total = WebBusinessImpl.getInstance().countTable("sms_user",con);
	String s = ExtJsonBuilder.toExtJsonString(total,  WebBusinessImpl.getInstance().pageQuery(SmsUser.class,"sms_user",con,currentPage,pageSize,orderStr));
	response.getWriter().print(s);
	return;
}else{//若选中了那么将显示该业务员所未被授权的成员列表
 	List<SmsUser> list = WebBusinessImpl.getInstance().findAllUsersNotBelongOperator(currentUserId,selectOperator);
	int total = list==null?0:list.size();
	response.getWriter().print(ExtJsonBuilder.toExtJsonString(total,list));
	return;
}

}
///////////////////////////////////////////////////////////////





%>
